package morncloud.com.notes.database;

import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


/**
 * Created by majoy on 2015/1/5.
 */
public class NoteDataBaseOpenHelper extends SQLiteOpenHelper {
    public NoteDataBaseOpenHelper(Context context) {
        this(context, null, null, 0);
    }

    public NoteDataBaseOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, Provider.DATABASE_NOTE, factory, Provider.DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        try {
            db.beginTransaction();
            db.execSQL(Provider.TABLE_NOTES_CREATE_SQL);
            db.execSQL(Provider.TABLE_NOTES_TRIGER);
            db.setTransactionSuccessful();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            db.endTransaction();
        }


    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
